package issr.boundary.vaadin;

import com.vaadin.ui.Alignment;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import issr.boundary.PannelloLogout;

public class Header extends HorizontalLayout {

    HorizontalLayout layout;
    Panel panel;
    Label label;
    // Header Components

    public Header() {
        setWidth("100%");
        panel = new Panel();
        panel.setSizeFull();
        panel.setScrollable(false);
        panel.setHeight("150");
        panel.setWidth("100%");
        layout = new HorizontalLayout();
        layout.setHeight("100%");
        layout.setWidth("100%");
        layout.setSpacing(true);
        layout.setMargin(true);
        label = new Label(MainApplication.getProject().getMainWindow().getCaption());
        layout.addComponent(label);
        panel.setContent(layout);
        addComponent(panel);
    }

    public void addLogoutComponent(PannelloLogout logout) {
        layout.addComponent(logout);
        layout.setComponentAlignment(logout, Alignment.MIDDLE_RIGHT);
    }

    public void removeLogoutComponent() {
        layout.removeComponent(layout.getComponent(layout.getComponentCount()-1));
    }
}
